echo Generating data

python paddleocr/tianchi/gen_det_data.py --data_dir /tcdata --output_dir labels
python paddleocr/tianchi/gen_rec_data.py --data_dir /tcdata --output_dir text
cp text/tianchi_dict.txt config/

# python paddleocr/tianchi/gen_det_data.py --data_dir /home/aistudio/data/tianchi --output_dir labels --mode 1
# python paddleocr/tianchi/gen_rec_data.py --data_dir /home/aistudio/data/tianchi --output_dir text --mode 1
# cp text/tianchi_dict.txt config/

ls text/train1 | wc -l
ls text/train2 | wc -l

python paddleocr/tianchi/trunc_pretrained.py --input models/db_r50_pretrained/best_accuracy.pdparams \
    --output models/pretrained/db_r50_trunced.pdparams --type 1

python paddleocr/tianchi/trunc_pretrained.py --input models/crnn_r34_pretrained/best_accuracy.pdparams \
    --output models/pretrained/crnn_r34_trunced.pdparams --type 0

echo Start detection training
python paddleocr/tools/train.py -c config/db_r50_dcn.yml \
    -o Global.pretrained_model=models/pretrained/db_r50_trunced.pdparams

echo Export detection inference model
python paddleocr/tools/export_model.py -c config/db_r50_dcn.yml \
    -o Global.pretrained_model=output/db_r50_dcn/latest \
        Global.save_inference_dir=models/db_r50_dcn

echo Start recoginition training
python paddleocr/tools/train.py -c config/crnn_r34.yml \
    -o Global.pretrained_model=models/pretrained/crnn_r34_trunced.pdparams

echo Export recoginition inference model
python paddleocr/tools/export_model.py -c config/crnn_r34.yml \
    -o Global.pretrained_model=output/crnn_r34/latest \
       Global.save_inference_dir=models/crnn_r34
    


python paddleocr/tianchi/infer_server.py \
    --det_model_dir models/db_r50_dcn\
    --cls_model_dir models/cls_mobile \
    --rec_model_dir models/crnn_r34 \
    --rec_char_dict_path config/tianchi_dict.txt \
    --use_angle_cls=True \
    --det_limit_side_len=1120 \
    --det_limit_type=resize_padding \
    --det_db_box_thresh=0.5 \
    --det_db_thresh=0.2 \
    --det_db_unclip_ratio=1.5 \
    --use_dilation=True \
    --use_space_char=True 
